<include file="public/head" />
</head>
<body>
<div class="am-modal am-modal-alert" tabindex="-1" id="fq_alert">
  <div class="am-modal-dialog">
    <div class="am-modal-hd" id="fq_alert_title"></div>
    <div class="am-modal-bd" id="fq_alert_info">
    </div>
    <div class="am-modal-footer">
      <span class="am-modal-btn">确定</span>
    </div>
  </div>
</div>
<div class="am-modal am-modal-confirm" tabindex="-1" id="fq_confirm">
  <div class="am-modal-dialog">
    <div class="am-modal-hd" id="fq_confirm_title"></div>
    <div class="am-modal-bd" id="fq_confirm_info"></div>
    <div class="am-modal-footer">
      <span class="am-modal-btn" data-am-modal-confirm="">确定</span>
    </div>
  </div>
</div>

<link rel="stylesheet" href="__STATIC__/itaoke/mobile/css/integralmall.css">
<script src="__STATIC__/itaoke/mobile/js/lArea.min.js"></script>
<!-- modal start -->
<div class="prompt am-vertical-align am-text-center">
    <div class="am-vertical-align-middle am-padding-vertical am-padding-horizontal">
        <span>订单编号在您手机淘宝的订单详情里哟~</span>
        <br>
        <span>——— 示例 ———</span>
        <br>
        <img src="__STATIC__/itaoke/mobile/images/No.png" class="am-margin-top">
        <br>
        <a class=" am-submit am-text-default am-padding-vertical-xs am-margin-top am-padding-horizontal-lg ">确定</a>
    </div>
</div>

<div class="am-modal am-modal-confirm" tabindex="-1" id="fq_true_confirm">
    <div class="am-modal-dialog">
        <div class="am-modal-hd" id="fq_true_confirm_title"></div>
        <div class="am-modal-bd" id="fq_true_confirm_info"></div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" data-am-modal-cancel="">取消</span>
            <span class="am-modal-btn" data-am-modal-confirm="">确定</span>
        </div>
    </div>
</div>

<!--iphone/android弹窗提示打开手机浏览器-->
<div class="safari_top">
    <div class="tinymask am-padding-0 am-margin-0"></div>
    <div class="safari_img am-text-right" onclick="hidetip()">
        <img id="go_tip" src="__STATIC__/itaoke/mobile/images/jump_coupon_android.png" alt="">
    </div>

</div>

<!--iphone/android弹窗领取优惠券-->
<!-- modal end -->
<div class="am-bd">
    <header style="position:relative;z-index:999;background:#F54D23;">
    <a href="javascript:void(0);" onclick="back();" style="position:absolute;top:2px;color:#fff;width:45px;height:100%;padding-left:10px;font-size:25px;" class="am-inline-block am-text-middle am-icon-angle-left"><!-- <img src="/Public/assets/mobile/images/left.png" />--></a><div class="am-per-center am-text-center am-padding-vertical-sm" style="color:#fff;font-size:16px;">兑换步骤</div>
</header>

<script>
    function back(){
       var last_page_url = (document.referrer);
       if(last_page_url){
          	window.history.back();
		}else{
			window.location.href ='{:U('User/index')}';
		}
    }
</script>
    <!--    商品信息-->
    <div class=" am-display am-padding-sm am-padding-horizontal-sm ">
        <div data-am-widget="gallery" data-am-gallery="{  pureview: 'true' }" class="am-no-layout">
            <img src="{:attach(str_replace('_s.'.array_pop(explode('.', $item['img'])), '_b.'.array_pop(explode('.', $item['img'])), $item['img']), 'score_item')}" class="am-img am-fl am-margin-right-xs" data-am-pureviewed="1">
                <div class="am-order am-text-xs am-text-center am-margin-right-xs"><span style="display:inline-block; position:relative;top:-2px">ID：<span class="prizeid" style="display:inline-block; position:relative;">{$item.id}</span></span></div>
        </div>
        <div><strong class="line-clamp am-margin-bottom-sm">{$item.title} </strong></div>
        <span class="credit am-text-xs am-fl">积分：<span class="am-credit am-text-xs deduct_score">{$item.score}</span> 分</span>
        <br>
        <div>
            <span class=" price am-text-xs">市场价：¥<span class="am-price am-text-xs">{$item.price}</span></span>
            <span class="volume am-fr am-text-xs">券后价：<span class="am-volume am-text-xs">¥{$item.coupon_price}</span></span>
        </div>
    </div>
    <!--自主发货商品-->
       <!-- 默认信息-->
       <notempty name="address">
        <div class="am-receipt am-padding-vertical-sm am-g am-margin-top-xs  am-choice">
            <div class="am-u-sm-11">
                <div class="am-margin-left-sm">
                        <div>
                        <span><strong>收货人：<span class="am-text-default default_name chance_name">{$address.username}</span></strong></span>
                        <span class="am-phone am-fr"><strong class="default_phone chance_phone">{$address.phone}</strong></span>
                        </div>
                        <div class="am-margin-top-xs am-address am-inline-block">收货地址：<span class="default_address chance_add">{$address.address}</span></div>
                </div>                                               
            </div>
            <a class="am-fr am-u-sm-1 am-padding-vertical" href="#">
                 <i class="am-icon-chevron-right am-fr am-margin-right-sm"></i>
                </a>
        </div>

        <!--下拉选择地址开始-->
        <div class="select_address">
        <volist name="alladdress" id="vo">
	        <div class="am-select am-padding-top-xs first_address" style="display:none;">
	            <a href="#" class="am-inline-block add-first am-text-sm  am-padding-horizontal-sm am-padding-vertical-xs " style="width: 100%;">
	                <span class=" am-fl am-name">{$vo.username}</span>
	                <span class=" am-fr am-number ">{$vo.phone}</span>
	                <span class=" am-fl am-add am-padding-top-xs " style="clear: both"><span class="am-selection"><if condition="$vo['ison'] eq 1">[默认地址]</if></span> <span class="get_add">{$vo.address}</span></span>
	            </a>
	        </div>
	    </volist>
        </div>
		</notempty>
        <!--下拉选择地址结束-->

   <!--  新增收货人信息-->

        <div class="am-new am-padding-vertical-sm am-padding-left-sm am-margin-top-xs ">
                <!--新增按钮-->
                <div class=" am-added am-text-center " style="display: block;">
                    <a class="add_info">
                        <i class="am-icon-plus-circle am-icon-md am-margin-right-xs"></i>
                            新增收货人信息
                    </a>
                </div> 
                <!--展开详情-->
                <div class="am-details" style="display: none;">
                <div class="am-newlytitle am-text-default am-padding-left-sm  am-inline-block"><strong>新增收货人信息</strong></div>
                    <a class="am-cancel am-inline-block am-fr am-margin-right-sm am-padding-horizontal-sm" style="border:.1rem solid #f3e7e3">取消编辑</a>
                    <div class="am-newly am-vertical-align am-text-sm">
                        收货人姓名：<input type="text" class="consignee_name" name="consignee_name">
                    </div>
                    <div class="am-newly am-vertical-align am-text-sm">
                        手机号码：<input type="text" class="consignee_phone" name="consignee_phone">
                    </div>
                     <div class="am-newly am-vertical-align am-text-sm" id="city">
                        所在地区：<input id="area" type="text" readonly="" name="input_area" placeholder="请选择城市">
                    </div>
                    <div class="am-address am-vertical-align am-text-sm">
                        <div class="am-margin-top-sm am-margin-top-sm am-inline-block">详情地址： </div>
                        <textarea class="am-margin-top-xs am-padding-top-xs" rows="5" id="doc-ta-1" name="consignee_address" value=""></textarea>
                    </div>
                </div>    
            </div>
            <div class="am-text-center post_sub"><button class="am-btn am-direct am-radius am-padding-horizontal-sm am-padding-vertical-xs am-margin-top-sm am-vertical-align-middle myitem_sub">立即兑换</button></div>
        <!--自主发货商品-->
</div>

<include file="public/foot" />

<style>
    /*弹窗*/
    .prompt {
        display: none;
        position: fixed;
        width: 100%;
        height: 100%;
        background: rgba(143,143,143,0.5);
        z-index: 100;
    }
        .prompt div {
            color: #c98080;
            border-radius: .5rem;
            background: white;
        }
        .prompt img {
            width: 18.7rem;
            height: 14rem;
        }

    .am-submit {
        border: .1rem solid #f54d23;
        color: #f54d23;
    }

    .line-clamp {
        -webkit-line-clamp: 2;
        max-height: 3.5rem;
    }
    .am-exchange {
        background: #f54d23;
    }

    /*淘宝购买/直接收货/新增信息详情/*/
    .am-receive,
    .am-receipt,
    .am-new {
        background: white;
    }
    .am-phone {
        line-height: 2;
    }
    .am-address,
    .am-newly,
    .am-first,
    .am-text {
        color: #8f8f8f;
    }

    .am-newly {
        height: 40px;
        border-bottom: .1rem solid #f3e7e3;
    }
        .am-newly input {
            color: #3d0505;
            line-height: 2;
            border: none;
        }
        .am-newly a {
            padding-top: 9px;
            padding-bottom: 9px;
        }
    .am-newlytitle {
        border-left: .3rem solid #f54d23;
    }
    select {
        border: 0;
    }
    textarea {
        color: #3d0505;
        width: 75%;
        border: 0;
        resize: none;
    }
    .am-details {
        display: none;
    }
    .am-icon-plus-circle,
    .am-exchange {
        color: #f54d23;
    }
    .am-exchange,
    .am-command,
    .am-text {
       width: 95%;
        height: 36px;
    }
        .am-exchange a {
            color: white;
            position: relative;
            top: 1px;
        }
    .am-command {
        width: 100%;
        background: white;
        color: #3d0505;
        border: .1rem dashed #f54d23;
        white-space: nowrap;
    }
    .am-text {
        width: 100%;
        border: .1rem solid #f54d23;
    }

    .edit_order, .check_score, .add_order {
        width: 90%;
        font-size: 1.4rem;
        border: .1rem solid #f54d23;
        background: white;
        height: 36px;
    }

    .am-explain {
        line-height: 1.8rem;
        background: white;
        color: #c98080;
    }

    p {
        text-decoration: underline;
    }

    .safari_top {
        display: none;
    }

    .safari_img {
        z-index: 2000;
        position: fixed;
        top: 10px;
        right: 0;
        position: fixed;
        z-index: 2000;
    }
        .safari_img img {
            width: 100%;
            margin: 0px;
        }

    .tinymask {
        z-index: 2000;
        width: 100%;
        height: 100%;
        position: fixed;
        top: 0;
        left: 0;
        background-color: rgba(0,0,0,0.7);
        -webkit-tap-highlight-color: transparent;

    }

    .abort {
        width: 100%;
        margin: 20px 0px 40px 0px;
        text-align: center;
    }

        .abort a {
            width: 90%;
            padding: 25px 0px;
            border-radius: 18px;
            color: #fff;
            background: #e74646;
            text-decoration: none;

        }

            .abort a.brc {
                opacity: 0.8;
            }

    .am-del {
        background: rgba(61,5,5,0.5);
        color: white;
        position: absolute;
        top: 55px;
        height: 63px;
        width: 63px;
    }

    .am-itemdown {
        position: absolute;
        top: 27px;
        left: 1px;
    }

    .order_num {
        outline: none;
        -webkit-appearance: none;
    }

    /*选择地址*/
    .add-first {
        background: white;
        border-bottom: .1rem solid #f3e7e3;
    }
    .am-selection {
        color: #f54d23;
    }

    .am-add {
        color: #8f8f8f;
    }

    .am-pagination > .am-active > a {
        background-color: #f54d23;
        border-color: #f54d23;
    }


    .am-style-list {
        padding: 0px;
    }

        .am-style-list li {
            list-style-type: none;
        }

    .am-receipt a:hover,
    .am-receipt a:focus {
        color: #3d0505;
    }


    /*地区联动样式*/
    body {
        -webkit-overflow-scrolling: touch;
        overflow-scrolling: touch;
    }

    .gearArea{
        background-color: rgba(0,0,0,0.2);
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 9900;
        overflow: hidden;
        -webkit-animation-fill-mode: both;
    }

    .area_ctrl {
        vertical-align: middle;
        background-color: white;
        margin: 0;
        height: auto;
        width: 100%;
        position: absolute;
        left: 0;
        bottom: 0;
        z-index: 9901;
        overflow: hidden;
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }

    .slideInUp {
        animation: slideInUp .3s ease-in;
       -webkit-animation: slideInUp .3s ease-in;
    }
    @-webkit-keyframes slideInUp {
        from {
            -webkit-transform: translate3d(0, 100%, 0);
           transform: translate3d(0, 100%, 0);
        }
        to {
            -webkit-transform: translate3d(0, 0, 0);
            transform: translate3d(0, 0, 0);
       }
    }

    .area_roll {
        display: -webkit-box;
        width: 100%;
        height: auto;
        overflow: hidden;
        font-weight: bold;
        background-color: transparent;
        -webkit-mask: -webkit-gradient(linear, 0% 50%, 0% 100%, from(#debb47), to(rgba(36,142,36,0)));
        -webkit-mask: -webkit-linear-gradient(top, #debb47 50%, rgba(36,142,36,0));
    }

        .area_roll > div {
            height: 8em;
            float: left;
            background-color: transparent;
            position: relative;
            overflow: hidden;
            -webkit-box-flex: 1;
        }

    .area_roll_mask {
        -webkit-mask: -webkit-gradient(linear, 0% 40%, 0% 0%, from(#debb47), to(rgba(36,142,36,0)));
        -webkit-mask: -webkit-linear-gradient(bottom, #debb47 50%, rgba(36,142,36,0));
        padding: 0 0 3em 0;
    }
    .area_grid {
        position: relative;
        top: 4em;
        width: 100%;
        height: 2em;
        margin: 0;
        box-sizing: border-box;
        z-index: 0;
        border-top: 1px solid #e6e6e6;
        border-bottom: 1px solid #e6e6e6;
    }

    .area_roll > div:nth-child(3) .area_grid > div {
        left: 42%;
    }

    .area_btn {
        text-align: center;
        padding: .8em 1em;
        cursor: pointer;
    }

    .area_btn_box {
        display: -webkit-box;
        -webkit-box-pack: justify;
        -webkit-box-align: stretch;
    }

    .gear {
        float: left;
        position: absolute;
        z-index: 9902;
        width: 5.5em;
        margin-top: 4em;
    }

    .area_roll > div .gear {
        width: 100%;
    }

    .tooth {
        height: 2em;
        line-height: 2em;
        text-align: center;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /*完结*/
</style>
<div class="am-hide"></div>
<script>
    $(document).ready(function () {

        //弹窗规则介绍
        $(".tips").click(function () {
            $(".prompt").css("display", "block");
            $(document.body).css({
                "overflow": "hidden"
            });
        });
        $(".am-submit").click(function () {
            $(".prompt").css("display", "none");
            $(document.body).css({
                "overflow-y": "auto"
            });
        });

        //选择收货地址显影
        $(".am-choice").click(function () {
            var display = $('.am-select').css('display');
            if (display == 'block') {
                $(".am-choice i").removeClass("am-icon-chevron-down");
                $(".am-choice i").addClass("am-icon-chevron-right");
                $(".am-more").addClass("am-hide");
            }
            if (display == 'none') {
                $(".am-choice i").removeClass("am-icon-chevron-right");
                $(".am-choice i").addClass("am-icon-chevron-down");
                $(".am-more").removeClass("am-hide");
            }
            $('.am-select').slideToggle();
        });

        //取消编辑按钮
        $(".am-cancel").click(function () {
            $(".am-details").css("display", "none");
            $(".am-added").css("display", "block");
            $('.post_sub').html('<button class="am-btn am-direct am-radius am-padding-horizontal-sm am-padding-vertical-xs am-margin-top-sm am-vertical-align-middle myitem_sub">立即兑换</button>');
        });
        //点击新增收货人信息
        $(".am-added").click(function () {
            $(".am-added").css("display", "none");
            $(".am-details").css("display", "block");
        });

        //选择地址
        $('.select_address').on('click', '.am-select', function () {
            var name = $(this).find('.am-name').text();
            var phone = $(this).find('.am-number').text();
            var add = $(this).find('.get_add').text();
            $('.chance_name').html(name);
            $('.chance_phone').html(phone);
            $('.chance_add').html(add);
            $('.am-select ').hide();
            $('.am-more').addClass('am-hide');
            $(".am-choice i").removeClass("am-icon-chevron-down");
            $(".am-choice i").addClass("am-icon-chevron-right");
        });
        //兑换按钮文字变化
        $('.add_info').click(function () {
            $('.post_sub').html('<button class="am-btn am-direct am-radius am-padding-horizontal-sm am-padding-vertical-xs am-margin-top-sm am-vertical-align-middle keep_add">保存地址</button>');
        });
        //保存地址
        $('.post_sub').on('click', '.keep_add', function () {
            var consignee_name = $.trim($('.consignee_name').val());
            var consignee_phone = $.trim($('.consignee_phone').val());
            var city = $.trim($('#area').val());
            var newcity = city.replace(/\s+/g, "");
            var detail_address = $.trim($('#doc-ta-1').val());
            var consignee_address = newcity + detail_address;//根据选择城市和详细地址的合并结果
            var is_reload=$(this).attr('data-reload');
            if (consignee_name == '') {
                $("#fq_alert_info").html("亲，请输入收货人姓名哦");
                $('#fq_alert').modal();
                return false;
            }
            if (consignee_phone == '') {
                $("#fq_alert_info").html("亲，请输入收货人号码哦");
                $('#fq_alert').modal();
                return false;
            }
            if (!(/^1[3|4|5|7|8]\d{9}$/.test(consignee_phone))) {
                $("#fq_alert_info").html("亲，请输入正确的手机号哦");
                $('#fq_alert').modal();
                return false;
            }
            if (city == '') {
                $("#fq_alert_info").html("亲，请选择所在城市哦");
                $('#fq_alert').modal();
                return false;
            }
            if (detail_address == '') {
                $("#fq_alert_info").html("亲，请输入详细地址哦");
                $('#fq_alert').modal();
                return false;
            }

            $('.keep_add').html('保存中 <i class="am-icon-spinner am-icon-spin"></i>');
            $('.keep_add').prop('disabled', true);
            $.ajax({
                type: 'post',
                url: "{:U('User/address')}",
                data: { "consignee_name": consignee_name, 'consignee_phone': consignee_phone, 'consignee_address': consignee_address },
                dataType: 'json',
                success: function (data) {
                    if (data.status == 1) {
                        $('.post_sub').html('<button class="am-btn am-direct am-radius am-padding-horizontal-sm am-padding-vertical-xs am-margin-top-sm am-vertical-align-middle myitem_sub">立即兑换</button>');
                        if(data.data.reload ==1){
                            $("#fq_confirm_info").text(data.data.msg);
                            $('#fq_confirm').modal({
                                relatedTarget: this,
                                onConfirm: function () {
                                   location.reload();
                                },
                            });
                        }else{
                            $("#fq_alert_info").html(data.data.msg);
                            $('#fq_alert').modal();
                            $('.default_name').html(consignee_name);
                            $('.default_phone').html(consignee_phone);
                            $('.default_address').html(consignee_address);
                            $('.first_address').append('<div class="am-select" style="display:none;"><a href="#" class="am-inline-block add-first am-text-sm  am-padding-horizontal-sm am-padding-vertical-xs " style="width: 100%;"><span class=" am-fl am-name">' + consignee_name + '</span><span class=" am-fr am-number ">' + consignee_phone + '</span><span class=" am-fl am-add am-padding-top-xs " style="clear: both"><span class="get_add">' + consignee_address + '</span></span></a></div>');
                            $(".am-details").css("display", "none");
                            $(".am-added").css("display", "block");
                             $('.am-select ').hide();
                            //清空新增内容
                            $(".consignee_name").val("");
                            $(".consignee_phone").val("");
                            $("#area").val("");
                            $("#doc-ta-1").val("");
                            var address_len=$('.am-select').length;
                            if(address_len>=10){
                                $('.am-new').addClass('am-hide');
                            }
                        }
                    }else{
                        $("#fq_alert_info").html(data.data.msg);
                        $('#fq_alert').modal();
                        $('.keep_add').html('保存地址');
                        $('.keep_add').prop('disabled', false);
                    }
                },
                complete:function(XMLHttpRequest,status){
                    if(XMLHttpRequest.status == 200){
                    }else{
                        $('#fq_alert_info').text('网络连接超时！');
                        $('#fq_alert').modal({});
                        $('.keep_add').html('保存地址');
                        $('.keep_add').prop('disabled', false);
                    }
                }
            });
        });

        //积分兑换免拍订单商品
        $('.post_sub').on('click', '.myitem_sub', function () {
            /*$('.myitem_sub').prop('disabled', true);*/
            $('.myitem_sub').addClass('am-hide');
            var score = $('.deduct_score').text();
            var consignee_name = $('.default_name').text();
            var consignee_phone = $('.default_phone').text();
            var consignee_address = $('.default_address').text();
            if(consignee_phone==''||consignee_address==''){
                $("#fq_alert_info").html("亲，请输入联系方式跟地址哦！");
                $('#fq_alert').modal();
                return false;         
            }
            $("#fq_true_confirm_info").text('亲，兑换将扣除“' + score + '”积分');
            $('#fq_true_confirm').modal({
                relatedTarget: this,
                closeViaDimmer: false,
                onConfirm: function () {
                    $('.myitem_sub').html('提交中 <i class="am-icon-spinner am-icon-spin"></i>');
                    var prizeid = $('.prizeid').text();
                    $.ajax({
                        type: 'post',
                        url: "{:U('User/ajaxDelTrueChange')}",
                        data: { "prizeid": prizeid, 'score': score, 'consignee_name': consignee_name, 'consignee_phone': consignee_phone, 'consignee_address': consignee_address },
                        dataType: 'json',
                        success: function (data) {
                            if (data.status == 1) {
                                $('.myitem_sub').html('兑换成功');
                                $("#fq_confirm_info").text(data.data.msg);
                                $('#fq_confirm').modal({
                                    relatedTarget: this,
                                    onConfirm: function () {
                                        window.location.href = data.data.url;
                                    },
                                });
                            }else{
                                $("#fq_alert_info").html(data.data.msg);
                                $('#fq_alert').modal();
                                $('.myitem_sub').html('立即兑换');
                                $('.myitem_sub').prop('disabled', false); 
                            }
                        },
                        complete:function(XMLHttpRequest,status){
                            if(XMLHttpRequest.status == 200){
                            }else{
                                $('#fq_alert_info').text('网络连接超时！');
                                $('#fq_alert').modal({});
                                $('.myitem_sub').html('立即兑换');
                                /*$('.myitem_sub').prop('disabled', false);*/
                                $('.myitem_sub').removeClass('am-hide');
                            }
                        }
                    });
                },
                onCancel:function(){
                   /*$('.myitem_sub').prop('disabled', false); */
                    $('.myitem_sub').removeClass('am-hide');
                }
            });
        });

        //积分兑换订单商品
        $('.add_order').click(function () {
            var score = $('.deduct_score').text();
            var order_num = $.trim($('.order_num').val());
            if (order_num == '') {
                $("#fq_alert_info").html("亲，请输入您的订单号哦");
                $('#fq_alert').modal();
                return false;
            }
            if (order_num.match(/^\d{16}$/) == null) {
                $("#fq_alert_info").html("亲，订单号为16位数字哦");
                $('#fq_alert').modal();
                return false;
            }
            // $('.add_order').prop('disabled', true);
            $('.add_order').addClass('am-hide');
            $("#fq_true_confirm_info").text('亲，兑换将扣除“' + score + '”积分');
            $('#fq_true_confirm').modal({
                relatedTarget: this,
                closeViaDimmer:false,
                onConfirm: function () {
                    $('.add_order').html('提交中 <i class="am-icon-spinner am-icon-spin"></i>');                    
                    var order = $.trim($('.order_num').val());
                    var prizeid = $('.prizeid').text();
                    $.ajax({
                        type: 'post',
                        url: "/integralmall/addorder.html",
                        data: { "prizeid": prizeid, "order_num": order, 'score': score },
                        dataType: 'json',
                        success: function (data) {
                            if (data.status == 1) {
                                $('.add_order').html('兑换成功');
                                $("#fq_confirm_info").text(data.info);
                                $('#fq_confirm').modal({
                                    relatedTarget: this,
                                    onConfirm: function () {
                                        window.location.href = "/integralmall/history.html";
                                    },
                                });
                            }else{
                                $("#fq_alert_info").html(data.info);
                                $('#fq_alert').modal();
                                $('.add_order').html('确定');
                                /*$('.add_order').prop('disabled', false);*/
                                $('.add_order').removeClass('am-hide');
                            }
                        },
                        complete:function(XMLHttpRequest,status){
                            if(XMLHttpRequest.status == 200){
                            }else{
                                $('#fq_alert_info').text('网络连接超时！');
                                $('#fq_alert').modal({});
                                ('.add_order').html('确定');
                                $('.add_order').prop('disabled', false);

                            }
                        }
                    });
                },
                onCancel:function(){
                   // $('.add_order').prop('disabled', false);
                   $('.add_order').removeClass('am-hide'); 
                }
            });
        });

        //修改订单号
        $('.edit_order').click(function () {
            var order_num = $.trim($('.order_num').val());
            if (order_num == '') {
                $("#fq_alert_info").html("亲，请输入您的订单号哦");
                $('#fq_alert').modal();
                return false;
            }
            if (order_num.match(/^\d{16}$/) == null) {
                $("#fq_alert_info").html("亲，订单号为16位数字哦");
                $('#fq_alert').modal();
                return false;
            }
            $("#fq_true_confirm_info").text('亲，您确定要修改订单号吗？');
            $('#fq_true_confirm').modal({
                relatedTarget: this,
                onConfirm: function () {
                    $('.edit_order').html('提交中 <i class="am-icon-spinner am-icon-spin"></i>');
                    $('.edit_order').prop('disabled', true);
                    var eid = $('.edit_order').attr('data-eid');
                    var order_num = $.trim($('.order_num').val());
                    $.ajax({
                        type: 'post',
                        url: "/integralmall/edit_order.html",
                        data: { "eid": eid, "order_num": order_num },
                        dataType: 'json',
                        success: function (data) {
                            if (data.status == 1) {
                                $('.edit_order').html('提交成功');
                                $("#fq_confirm_info").text(data.info);
                                $('#fq_confirm').modal({
                                    relatedTarget: this,
                                    onConfirm: function () {
                                        window.location.href = "/integralmall/history.html";
                                    },
                                });
                            }else{
                                $("#fq_alert_info").html(data.info);
                                $('#fq_alert').modal();
                                $('.edit_order').html('修改订单号');
                                $('.edit_order').prop('disabled', false);
                            }
                        },
                        complete:function(XMLHttpRequest,status){
                            if(XMLHttpRequest.status == 200){
                            }else{
                                $('#fq_alert_info').text('网络连接超时！');
                                $('#fq_alert').modal({});
                                $('.edit_order').html('修改订单号');
                                $('.edit_order').prop('disabled', false);
                            }
                        }
                    });
                },
            });
        });
    });

    //自动focus定时器初始化
    var timer0 = "";
    var timer1 = "";
    var ua = navigator.userAgent.toLowerCase();
    function showtip() {
        var ua = navigator.userAgent.toLowerCase();
        if (ua.match(/iphone/i) == "iphone" || ua.match(/ipad/i) == "ipad") {
            $(".safari_top").css("display", "block");
            $("#go_tip").attr("src", "__STATIC__/itaoke/mobile/images/jump_coupon_ios.png");
        } else {
            $(".safari_top").css("display", "block");
            $("#go_tip").attr("src", "__STATIC__/itaoke/mobile/images/jump_coupon_android.png");
        }
    }
</script>
<script>
   $(function () {
        //事件监听

        //------------------------------------------    

        document.addEventListener("selectionchange", function (e) {
            if (window.getSelection().anchorNode.parentNode.id == 'copy_key_ios' && document.getElementById('copy_key_ios').innerText != window.getSelection()) {
                var key = document.getElementById('copy_key_ios');
                window.getSelection().selectAllChildren(key);
            }
        }, false);

        //内部方法
        function is_weixin() {
            var ua = navigator.userAgent.toLowerCase();
            if (ua.match(/MicroMessenger/i) == "micromessenger" || ua.match(/qq\//i) == "qq/") {
                return true;
            } else {
                return false;
            }
        }

        function is_ios() {
            var ua = navigator.userAgent.toLowerCase();
            if (ua.match(/iphone/i) == "iphone" || ua.match(/ipad/i) == "ipad") {
                return true;
            } else {
                $("#copy_key_ios").addClass('am-hide');
                $("#copy_key_android").removeClass('am-hide');
                return false;
            }
        }

        function openApp(url) {
            var tb_url = url.replace("http://", "").replace("https://", "");
            var ifr = document.createElement('iframe');
            ifr.src = 'taobao://' + tb_url;
            ifr.style.display = 'none';
            document.body.appendChild(ifr);
            window.location = url;
        }

        function openIphoneApp_ios_9(url) {
            var tb_url = url.replace("http://", "").replace("https://", "");
            window.location = "taobao://" + tb_url;
            window.setTimeout(function () { window.location = url; }, 4000);
        }

        //函数执行
        var isWeixin = is_weixin();
        if (isWeixin) {
            var is_ios = is_ios();
            //is_ios = 0;
            if (is_ios) {
                $("#go_tip").attr("src", "__STATIC__/itaoke/mobile/images/jump_coupon_ios.png");
            } else {
                $("#go_tip").attr("src", "__STATIC__/itaoke/mobile/images/jump_coupon_android.png");
                $("#copy_key_ios").addClass('am-hide');
                $("#copy_key_android").removeClass('am-hide');
            }
        } else {
            //var is_ios = is_ios();
            //is_ios=0;
            if (is_ios) {
                $("#go_tip").attr("src", "__STATIC__/itaoke/mobile/images/jump_coupon_ios.png");
            } else {
                $("#go_tip").attr("src", "__STATIC__/itaoke/mobile/images/jump_coupon_android.png");
                $("#copy_key_ios").addClass('am-hide');
                $("#copy_key_android").removeClass('am-hide');
            }
        }
    });
    var area = new lArea();
    area.init({
        'trigger': '#area',//控件ID
        'data': lAreaData//数组格式数据源，可扩展为自定义数据源

    });
</script>
</html>